//  终端登录
<template>
    <div class="login-wrap">
        <div class="model"></div>
        <div class="ms-title">gantt </div>
        <div class="ms-login">
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="demo-ruleForm">
                <el-form-item prop="loginAccount">
                    <el-input v-model="ruleForm.loginAccount" placeholder="用戶账号"></el-input>
                </el-form-item>
                <el-form-item prop="loginPassword">
                    <el-input type="password" placeholder="用户密码" v-model="ruleForm.loginPassword" @keyup.enter.native="submitForm('ruleForm')"></el-input>
                </el-form-item>
                <el-checkbox v-model="isChecks" >记住密码</el-checkbox>
                <div class="login-btn">
                    <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
                </div>
                <p style="font-size:12px;line-height:30px;color:#999;">Tips : 填写正确的用户名和密码。</p>
            </el-form>
        </div>
    </div>
</template>

<script>
    // const insurance = require( '../../api/insurance.js');        //  接口js引用
    export default {
        data: function(){
            return {
                isChecks: false,
                ruleForm: {
                    loginAccount: '',
                    loginPassword: ''
                },
                rules: {
                    loginAccount: [
                        { required: true, message: '请输入用户名', trigger: 'blur' }
                    ],
                    loginPassword: [
                        { required: true, message: '请输入密码', trigger: 'blur' }
                    ]
                }
            }
        },
        methods: {
            // 获取当前缓存用户信息
            getUserInfo(){
                var username =  localStorage.getItem('ms_username');
                var userpwd = localStorage.getItem('ms_userpwd');
                console.log(username+'--'+userpwd)
                if(username != null && userpwd != null ){
                    this.ruleForm.loginAccount = localStorage.getItem('ms_username');
                    this.ruleForm.loginPassword = localStorage.getItem('ms_userpwd');
                    this.isChecks = true;
                }else{
                    this.ruleForm.loginAccount = '';
                    this.ruleForm.loginPassword = '';
                }
            },
            // 登录
            submitForm(formName) {
                var that = this;
                that.$router.push('/page');
                localStorage.setItem('ms_username','admin');
                localStorage.setItem('ms_userpwd','123456');
                // that.$refs[formName].validate((valid) => {
                //     if (valid) {
                //         var data = 'FLD_NAME='+that.ruleForm.loginAccount+'&FLD_PSWD='+that.ruleForm.loginPassword;
                //         $.ajax({
                //             url:insurance.posturl2+"SysInfo/UserLogin?"+data,
                //             type:"POST",
                //             success:function(data){
                //                 if(data.status){
                //                     localStorage.setItem('ms_username',that.ruleForm.loginAccount);
                //                     localStorage.setItem('ms_userpwd',that.ruleForm.loginPassword);
                //                     localStorage.setItem('ms_usercity',data.data.FLD_FLEET_ID);
                //                     localStorage.setItem('ms_remember',that.isChecks);
                //                     that.$router.push('/page');
                //                 }else{
                //                     that.$message.error(data.msg);
                //                 }
                //             },
                //             error: function(jqXHR){
                //                 that.$message.error('发生错误'+jqXHR.status);
                //             }
                //         });
                //     } else {
                //         that.$message.error('请填写完整');
                //     }
                // });
            }
        },
        mounted(){
            this.getUserInfo();
        }
    }


</script>
<!--<style src="../../../static/css/datasource.css"></style>-->

@import url("//unpkg.com/element-ui/lib/theme-default/index.css");
<style scoped>
    .ms-login input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
        background-color: red !important;
        background-image: none !important;
        color: rgb(0, 0, 0) !important;
    }
    .login-wrap{
        position: relative;
        width:100%;
        height:100%;
    }
    .ms-title{
        position: absolute;
        top:50%;
        width:100%;
        margin-top: -230px;
        text-align: center;
        font-size:30px;
        color: #fff;

    }
    .ms-login{
        position: absolute;
        left:50%;
        top:50%;
        width:300px;
        height:185px;
        margin:-150px 0 0 -190px;
        padding:40px;
        border-radius: 5px;
        background: #fff;
    }
    .login-btn{
        text-align: center;
    }
    .login-btn button{
        width:100%;
        height:36px;
    }
</style>

